﻿@model APIService.Models.UserInfo

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>
<div>
    <div>
        <fieldset>
            <legend>UserInfo</legend>

            <div class="editor-label">
                @Html.LabelFor(model => model.UserName)
            </div>
            <div class="editor-field">
                <input id="textboxforUserName" type="text" />
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Address)
            </div>
            <div class="editor-field">
                <input id="textboxforAddress" type="text" />
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.CreateTime)
            </div>
            <div class="editor-field">
                <input id="textboxforCreateTime" type="text" />
            </div>

            <p>
                <input type="button" id="submitUser" value="Create" />
            </p>
        </fieldset>


        <div>
            @Html.ActionLink("Back to List", "Index")
        </div>
    </div>
    <div>
        <input type="button" id="btnReadAPI" value="Read API" />
        <div id="resultDIV"></div>
    </div>
</div>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
<script type="text/javascript">
    $(function () {
        $("#submitUser").click(function () {
            var userName = $("#textboxforUserName").val();
            var address = $("#textboxforAddress").val();
            var createTime = $("#textboxforCreateTime").val();

        });

        $("#btnReadAPI").click(function () {
            debugger;
            var news = {
                start: 0,
                count: 5,
                getLatest: 0,
                basetime:''
            };
            $.ajax({
                url: "/api/news/GetNews",
                data: news,
                type: "GET",
                async: false,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    debugger;
                    var result = response.record;
                    $("#resultDIV").html("");
                    var content = '';
                    for (var i = 0; i < result.length; i++) {
                        content +=" "+ result[i].caption+";";
                    }
                    $("#resultDIV").html(content);
                }
            });

        });

    });
</script>
